﻿// VirtualRegisters.cs
// Class that represents virtual registers in the arm architecture


namespace armsim
{
    /// <summary>
    /// Register class that uses many of the methods provided in VirtualMemory which it inherits from
    /// </summary>
    public class VirtualRegisters : VirtualMemory
    {
        /// <summary>
        /// Initializes a new VirtualRegisters class. It will always be 68 bytes
        /// </summary>
        public VirtualRegisters() 
        {
            this.ByteArray = new byte[68];
        }

        /// <summary>
        /// Special Case register ReadWord that handles PC reads by adding 4 to the address.
        /// </summary>
        /// <param name="address">the address to read from.</param>
        /// <returns>the address of the data to read from the registers</returns>
        public uint ReadRegistersDuringExecute(uint address)
        {
            var i = (address == VirtualMemory.PC ? 4u : 0u);
            return base.ReadWord(address) + (address == VirtualMemory.PC ? 4u : 0u);
        }

    }
}
